import { Graphics, Layers } from "cc";

export class Dot extends Graphics {
  public velocityX:number;

  public velocityY:number;

  public maxDistance: number;

  protected start(): void {
    const angle:number = Math.random() * 2 * Math.PI;
    const distance:number = Math.random() * this.maxDistance;
    const speed:number = Math.random() * 10 + 10;
    this.velocityX = Math.cos(angle) * speed;
    this.velocityY = Math.sin(angle) * speed;

    this.node.layer = Layers.Enum.UI_2D;
    this.fillColor.fromHEX('#ffffff');
    this.circle(0, 0, 1);
    this.stroke();
    this.fill();
    this.node.setPosition(Math.cos(angle) * distance, Math.sin(angle) * distance);
  }
}
